﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Treely.Data;
using Treely.Data.Repositories;

namespace TreelyConsole
{
    internal class AdminConsole
    {
        internal AdminConsole()
        {
            MainMenu();
        }

        public static void MainMenu()
        {
            Prompt();
        }

        public static void Prompt()
        {
            var options = new List<string>() { "QUIZ", "ASSESSMENT", "STUDENT", "USER" };
            var response = Prompt("Which object would you like to access?", options);
            switch (response.ToUpper())
            {
                case "QUIZ":
                    PromptQuiz();
                    break;

                case "ASSESSMENT":
                    PromptAssessment();
                    break;

                case "STUDENT":
                    PromptStudent();
                    break;

                case "USER":
                    PromptUser();
                    break;

                default:
                    Console.WriteLine("No valid argument supplied.");
                    break;
            }
        }

        public static void PromptQuiz()
        {
        }

        public static void PromptAssessment()
        {
        }

        public static void PromptStudent()
        {
        }

        public static void PromptUser()
        {
        }

        public static string Prompt(string promptText, List<string> options)
        {
            string response = string.Empty;
            while (!options.Any(x => x.Equals(response, StringComparison.OrdinalIgnoreCase)))
            {
                Console.WriteLine(promptText);
                Console.WriteLine("Options are: ");
                options.ForEach(Console.WriteLine);
                response = Console.ReadLine();
                if (options.Any(x => x.Equals(response, StringComparison.OrdinalIgnoreCase)))
                    return response;
            }
            throw new ApplicationException("Prompt loop error.");
        }
    }
}